package com.vidyu.businesslayer.businessentities;

import com.google.common.collect.Lists;

import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * User: eyalsa
 * Date: 3/31/13
 * Time: 5:33 PM
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table(name = "contractors")
@NamedQueries({
        @NamedQuery(
                name = "getContractorByEmail",
                query = "FROM com.vidyu.businesslayer.businessentities.Contractor as contractor WHERE  contractor.email = ?"
        ),
        @NamedQuery(
                name = "getContractorByEmailAndPassword",
                query = "FROM com.vidyu.businesslayer.businessentities.Contractor as contractor WHERE contractor.email = ? AND contractor.password = ?"
        )})
public class Contractor extends User implements Serializable{
    private static final long serialVersionUID = 3277107386711729397L;

    private int totalHours;
    private double pricePerHour;
    private String title;
    private String contraDesc;
    private Set<Skill> skillSet;
    private String firstProt;
    private String secondProt;
    private String thirdProt;
    private String forthProt;
    private String fifthProt;



    public Contractor(){}

    public Contractor(String name, String email, String password, String address, String country, double pricePerHour,
                      String title, String contraDesc) {
        super(name, email, password, address, country);
        this.pricePerHour = pricePerHour;
        this.title = title;
        this.contraDesc = contraDesc;
    }

    public int getTotalHours() {
        return totalHours;
    }

    public void setTotalHours(int totalHours) {
        this.totalHours = totalHours;
    }

    public double getPricePerHour() {
        return pricePerHour;
    }

    public void setPricePerHour(double pricePerHour) {
        this.pricePerHour = pricePerHour;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContraDesc() {
        return contraDesc;
    }

    public void setContraDesc(String contraDesc) {
        this.contraDesc = contraDesc;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinTable(name = "contractor_to_projects_connection", joinColumns = @JoinColumn(name = "contractor_id"), inverseJoinColumns = @JoinColumn(name = "project_id"))
    public Set<Project> getProjectSet() {
        return projectSet;
    }

    public void setProjectSet(Set<Project> projectSet) {
        this.projectSet = projectSet;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinTable(name = "contractor_to_skills_connection", joinColumns = @JoinColumn(name = "contractor_id"), inverseJoinColumns = @JoinColumn(name = "skill_id"))
    public Set<Skill> getSkillSet() {
        return skillSet;
    }

    public void setSkillSet(Set<Skill> skillSet) {
        this.skillSet = skillSet;
    }

    public String getFirstProt() {
        return firstProt;
    }

    public void setFirstProt(String firstProt) {
        this.firstProt = firstProt;
    }

    public String getSecondProt() {
        return secondProt;
    }

    public void setSecondProt(String secondProt) {
        this.secondProt = secondProt;
    }

    public String getThirdProt() {
        return thirdProt;
    }

    public void setThirdProt(String thirdProt) {
        this.thirdProt = thirdProt;
    }

    public String getForthProt() {
        return forthProt;
    }

    public void setForthProt(String forthProt) {
        this.forthProt = forthProt;
    }

    public String getFifthProt() {
        return fifthProt;
    }

    public void setFifthProt(String fifthProt) {
        this.fifthProt = fifthProt;
    }
}
